﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//
using ImeLib;
using System.Threading;

public partial class _Default : System.Web.UI.Page
{
    private string[] result = null;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ParameterizedThreadStart p = new ParameterizedThreadStart(GetBopomofo);
        Thread t = new Thread(p);
        t.SetApartmentState(ApartmentState.STA);
        t.Start(TextBox1.Text);
        t.Join();

        for (int i = 0; i < result.Length; i++)
        {
            Response.Write(result[i]);
        }
    }

    private void GetBopomofo(object o)
    {
        using (MsImeFacade ime = new MsImeFacade(ImeClass.Taiwan))
        {
            result = ime.GetBopomofo(o.ToString());
        }
    }
}
